#include<bits/stdc++.h>

using namespace std;

#define lowbit(x) (x & (-x))

typedef long long ll;

const int N = 200010;

int n,k;
int a[N];
int tr[N];
int g[N],l[N];

void add(int x, int c)
{
	for(int i = x; i <= n; i += lowbit(i)) tr[i] += c;
}

int sum(int x)
{
	int res = 0;
	for(int i = x; i; i -= lowbit(i)) res += tr[i];
	return res;
}

int main()
{
	cin>>n>>k;
	
	for(int i = 1; i <= k; i ++ )
	{
		char f;
		int m,p;
		cin>>f;
		if(f == 'A')
		{
			cin>>m;
			cout<<sum(m)<<endl;
		}
		else if(f == 'B')
		{
			cin>>m>>p;
			add(m, p);
		}
		else if(f == 'C')
		{
			cin>>m>>p;
			add(m, -p);
		}
	}
	return 0;
}

